home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / XML Utilities / Professional Programmer XSL IDE / Xselerator25.msi / Data.Cab / F17364_Books.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2001-09-24  |  1.6 KB  |  44 lines

  1. <?xml version="1.0"?>
  2. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  3. <xsl:output method="html" encoding="ISO-8859-1" indent="yes"/>
  4. <!-- Orders the output of books based on a priority based on -->
  5. <!-- the occurence of given words in the title of the book   -->
  6. <!-- e.g. 1st are any books with 'XSL' in the title          -->
  7. <!--      2nd are any books with 'ASP' in the title          -->
  8. <!--      3rd are any books with 'Java' in the title         -->
  9. <!--      then all other books are listed as is              -->
  10. <xsl:template match="/">
  11.     <html>
  12.         <head>
  13.             <title>Books by interest priority</title>
  14.         </head>
  15.         <body>
  16.             <h3>Books by interest priority</h3>
  17.             <table border="1">
  18.                 <tr>
  19.                     <th>Title</th>
  20.                     <th>Author</th>
  21.                     <th>ISBN</th>
  22.                     <th>Item No.</th>
  23.                 </tr>
  24.                 <xsl:apply-templates select="/books/book">
  25.                     <xsl:sort select="number(contains(title,'XSL'))" data-type="number" order="descending"/>
  26.                     <xsl:sort select="number(contains(title,'ASP'))" data-type="number" order="descending"/>
  27.                     <xsl:sort select="number(contains(title,'Java'))" data-type="number" order="descending"/>
  28.                 </xsl:apply-templates>
  29.             </table>
  30.         </body>
  31.     </html>
  32. </xsl:template>
  33.  
  34. <xsl:template match="book">
  35.     <tr>
  36.         <td><xsl:value-of select="title"/></td>
  37.         <td><xsl:value-of select="author"/></td>
  38.         <td><xsl:value-of select="@isbn"/></td>
  39.         <!-- show position of element in original xml -->
  40.         <td align="right"><xsl:value-of select="count(preceding-sibling::book)+1"/></td>
  41.     </tr>
  42. </xsl:template>
  43.  
  44. </xsl:stylesheet>